package demoMod.strongerheart.powers;

import com.megacrit.cardcrawl.core.AbstractCreature;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.localization.PowerStrings;
import com.megacrit.cardcrawl.powers.AbstractPower;
import demoMod.strongerheart.StrongerHeartMod;

public class InfinityCursePower extends AbstractPower {
    public static final String POWER_ID = StrongerHeartMod.makeID("InfinityCursePower");
    private static final PowerStrings powerStrings;
    public static final String NAME;
    public static final String[] DESC;
    private final int amount2;
    private int phase = 0;

    public InfinityCursePower(AbstractCreature owner, int initialAmount, int maxAmount) {
        this.owner = owner;
        this.amount = initialAmount;
        this.amount2 = maxAmount;
        this.ID = POWER_ID;
        this.name = NAME;
        this.updateDescription();
        this.loadRegion("brutality");
    }

    @Override
    public void updateDescription() {
        int index = Math.min(phase, 2);
        if (index < 2) {
            this.description = DESC[index];
        } else {
            this.description = String.format(DESC[index], AbstractDungeon.ascensionLevel >= 19 ? 300 : 200);
        }
    }

    @Override
    public void duringTurn() {
        this.amount--;
        if (this.amount <= 0) {
            this.flash();
            this.amount = this.amount2;
            this.phase++;
            this.updateDescription();
        }
    }

    @Override
    public void onDeath() {
        this.amount = this.amount2;
        this.phase++;
        this.updateDescription();
    }

    static {
        powerStrings = CardCrawlGame.languagePack.getPowerStrings(POWER_ID);
        NAME = powerStrings.NAME;
        DESC = powerStrings.DESCRIPTIONS;
    }
}
